const Sequelize = require('sequelize')
const sequelize = require('../libs/db')
class vote extends Sequelize.Model {}
vote.init(
  {
    voteId: {
      field: 'id',
      type: Sequelize.BIGINT,
      primaryKey: true,
      autoIncrement: true
    },
    voteName: {
      field: 'vote_name',
      type: Sequelize.STRING(100),
      allowNull: false,
      comment: '投票名称'
    },
    voteType: {
      field: 'vote_type',
      type: Sequelize.STRING(10),
      allowNull: false,
      defaultValue: 0,
      comment: '投票类型'
    },
    description: {
      field: 'description',
      type: Sequelize.TEXT,
      comment: '简介'
    },
    bgnDate: {
      field: 'bgn_date',
      type: Sequelize.DATEONLY,
      allowNull: true,
      comment: '投票开始时间'
    },
    endDate: {
      field: 'end_date',
      type: Sequelize.DATEONLY,
      allowNull: true,
      comment: '投票结束时间'
    },
    status: {
      field: 'status',
      type: Sequelize.SMALLINT,
      allowNull: true,
      comment: '上下架状态,int。1-上架；0-下架'
    },
    isFinished: {
      field: 'is_finished',
      type: Sequelize.SMALLINT,
      allowNull: true,
      defaultValue: 0,
      comment: '状态。1-已完结；0-未完结；-1-已完结（未投票成功）'
    },
    createdAt: {
      field: 'created_at',
      type: Sequelize.BIGINT
    },
    updatedAt: {
      field: 'updated_at',
      type: Sequelize.BIGINT
    }
  },
  {
    sequelize,
    modelName: 'vote',
    tableName: 'vote'
  }
)

module.exports = vote
